package com.yufeng.collaboration.service.impl;

import com.yufeng.collaboration.entity.Comment;
import com.yufeng.collaboration.mapper.CommentMapper;
import com.yufeng.collaboration.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {
    @Autowired
    private CommentMapper commentMapper;

    @Override
    public List<Comment> getCommentsByDocumentId(Integer documentId) {
        return commentMapper.selectList(new com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<Comment>().eq("document_id", documentId));
    }

    @Override
    public void addComment(Comment comment) {
        commentMapper.insert(comment);
    }

    @Override
    public void deleteComment(Integer id) {
        commentMapper.deleteById(id);
    }
}